package com.wm.job;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Scanner;

public class Test {

    public static HashMap<Integer,Job> list=new HashMap<>();

    public static void showJobList()
    {
        System.out.println("职位编号" + "\t"
                + "职位名称" + "\t"
                + "行业" + "\t"
                + "招聘人数" + "\t"
                + "发布时间");
        for(Object obj:list.keySet())
        {
            Job job = list.get(obj);
            SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            System.out.println(obj + "\t"
                    + job.getJobName() + "\t"
                    + job.getIndustry() + "\t"
                    + job.getNumber() + "\t" +
                    format.format(job.getPubDate()));
        }
    }

    public static void searchJobByName(String jobName)
    {
        System.out.println("职位编号" + "\t"
                + "职位名称" + "\t"
                + "行业" + "\t"
                + "招聘人数" + "\t"
                + "发布时间");
        for(Object obj:list.keySet())
        {
            Job job = list.get(obj);
            if(job.getJobName().indexOf(jobName) != -1)
            {
                SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                System.out.println(obj + "\t"
                        + job.getJobName() + "\t"
                        + job.getIndustry() + "\t"
                        + job.getNumber() + "\t" +
                        format.format(job.getPubDate()));
            }
        }
    }
    public static void data()
    {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Date date = new Date();
        list.put(1,new Job("Web前端","计算机",3,date));
        data();
        date = new Date();
        list.put(2,new Job("UI","计算机",6,date));
        data();
        date = new Date();
        list.put(3,new Job("JAVA工程师","计算机",13,date));
        data();
        date = new Date();
        list.put(4,new Job("数据库管理员","计算机",3,date));
        data();
        date = new Date();
        list.put(5,new Job(".NET开发","计算机",2,date));
        showJobList();
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你要查找的职位名称:");
        String name = in.next();
        searchJobByName(name);

    }

}
